package com.hanter.android.radwidget.statusbar;

import android.os.Build;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;

public class DefaultAdapter implements StatusBarModeAdapter {

    @Override
    public boolean isSupportLightMode() {
        return Build.VERSION.SDK_INT >= Build.VERSION_CODES.M;
    }

    @Override
    public boolean setStatusBarMode(Window window, boolean lightMode) {
        boolean result = false;
        int vis = window.getDecorView().getSystemUiVisibility();
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
            window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
            if (lightMode) {
                vis |= View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR;
            } else {
                vis &= ~View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR;
            }
            result = true;
        }
        window.getDecorView().setSystemUiVisibility(vis);
        return result;
    }
}
